/*
 * Copyright (C) 2013 'Chaos'.Personal
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.silly.adapter.utils;

import android.util.Log;

/**
 * 对程序Log进行统一管理，提供开关功能。
 * 
 * @author Chaos
 * @date 2013-3-29
 */
public enum RLog {
	V {
		@Override
		void print(String tag, String msg, Throwable t) {
			Log.v(tag, msg, t);
		}
	},
	D {
		@Override
		void print(String tag, String msg, Throwable t) {
			Log.d(tag, msg, t);
		}
	},
	I {
		@Override
		void print(String tag, String msg, Throwable t) {
			Log.i(tag, msg, t);
		}
	},
	W {
		@Override
		void print(String tag, String msg, Throwable t) {
			Log.w(tag, msg, t);
		}
	},
	E {
		@Override
		void print(String tag, String msg, Throwable t) {
			Log.e(tag, msg, t);
		}
	};

	abstract void print(String tag, String msg, Throwable t);

	public static boolean isDebugMode = true;

	public void p(String tag, String msg, Throwable t) {
		if (isDebugMode) {
			print(tag, msg, t);
		}
	}

	public void p(String tag, String msg) {
		p(tag, msg, null);
	}

	public void p(String msg, Throwable t) {
		p(CharConstants.TAG, msg, t);
	}

	public void p(String msg) {
		p(CharConstants.TAG, msg, null);
	}

	/**
	 * 类名(包含包名) + 输出信息
	 */
	public void p(Object o, String msg) {
		p(o.getClass().getName() + CharConstants.INDICATOR + msg);
	}
}
